<template>
  <ContentWrap>
    <!-- 搜索工作栏 -->
    <el-form
      class="-mb-15px"
      :model="queryParams"
      ref="queryFormRef"
      :inline="true"
      label-width="68px"
    >
			
			
      <el-form-item label="员工名称" prop="employeeName">
        <el-input
          v-model="queryParams.employeeName"
          placeholder="请输入员工名称"
          clearable
          @keyup.enter="handleQuery"
          class="!w-240px"
        />
      </el-form-item>
			
      <el-form-item label="员工编号" prop="employeeCode">
        <el-input
          v-model="queryParams.employeeCode"
          placeholder="请输入员工编号"
          clearable
          @keyup.enter="handleQuery"
          class="!w-240px"
        />
      </el-form-item>
			
      <el-form-item label="工作经历" prop="workBackground">
        <el-input
          v-model="queryParams.workBackground"
          placeholder="请输入工作经历"
          clearable
          @keyup.enter="handleQuery"
          class="!w-240px"
        />
      </el-form-item>
			
      <el-form-item label="性别" prop="sex">
        <el-select
          v-model="queryParams.sex"
          placeholder="请选择性别"
          clearable
          class="!w-240px"
        >
          <el-option label="请选择字典生成" value="" />
        </el-select>
      </el-form-item>
			
			
      <el-form-item label="兴趣爱好" prop="hobbies">
        <el-input
          v-model="queryParams.hobbies"
          placeholder="请输入兴趣爱好"
          clearable
          @keyup.enter="handleQuery"
          class="!w-240px"
        />
      </el-form-item>
			
      <el-form-item label="学历" prop="education">
        <el-input
          v-model="queryParams.education"
          placeholder="请输入学历"
          clearable
          @keyup.enter="handleQuery"
          class="!w-240px"
        />
      </el-form-item>
			
      <el-form-item label="打卡时间" prop="officeHours">
        <el-input
          v-model="queryParams.officeHours"
          placeholder="请输入打卡时间"
          clearable
          @keyup.enter="handleQuery"
          class="!w-240px"
        />
      </el-form-item>
			
      <el-form-item label="工作时间" prop="workingHours">
        <el-input
          v-model="queryParams.workingHours"
          placeholder="请输入工作时间"
          clearable
          @keyup.enter="handleQuery"
          class="!w-240px"
        />
      </el-form-item>
			
      <el-form-item label="出生日期" prop="birth">
        <el-input
          v-model="queryParams.birth"
          placeholder="请输入出生日期"
          clearable
          @keyup.enter="handleQuery"
          class="!w-240px"
        />
      </el-form-item>
			
      <el-form-item label="工作起止" prop="workDateFrom">
        <el-input
          v-model="queryParams.workDateFrom"
          placeholder="请输入工作起止"
          clearable
          @keyup.enter="handleQuery"
          class="!w-240px"
        />
      </el-form-item>
			
      <el-form-item label="信息保密" prop="privacy">
        <el-input
          v-model="queryParams.privacy"
          placeholder="请输入信息保密"
          clearable
          @keyup.enter="handleQuery"
          class="!w-240px"
        />
      </el-form-item>
			
			
      <el-form-item label="意见" prop="opinion">
        <el-input
          v-model="queryParams.opinion"
          placeholder="请输入意见"
          clearable
          @keyup.enter="handleQuery"
          class="!w-240px"
        />
      </el-form-item>
			
      <el-form-item label="是否可上岗" prop="mountGuard">
        <el-input
          v-model="queryParams.mountGuard"
          placeholder="请输入是否可上岗"
          clearable
          @keyup.enter="handleQuery"
          class="!w-240px"
        />
      </el-form-item>
			
      <el-form-item label="创建时间" prop="createTime">
        <el-date-picker
          v-model="queryParams.createTime"
          value-format="YYYY-MM-DD HH:mm:ss"
          type="daterange"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
          :default-time="[new Date('1 00:00:00'), new Date('1 23:59:59')]"
          class="!w-240px"
        />
      </el-form-item>
			
      <el-form-item label="完成进度" prop="slider21678">
        <el-input
          v-model="queryParams.slider21678"
          placeholder="请输入完成进度"
          clearable
          @keyup.enter="handleQuery"
          class="!w-240px"
        />
      </el-form-item>
      <el-form-item>
        <el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button>
        <el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button>
        <el-button
          type="primary"
          plain
          @click="openForm('create')"
          v-hasPermi="['form:emp-info:create']"
        >
          <Icon icon="ep:plus" class="mr-5px" /> 新增
        </el-button>
        <el-button
          type="success"
          plain
          @click="handleExport"
          :loading="exportLoading"
          v-hasPermi="['form:emp-info:export']"
        >
          <Icon icon="ep:download" class="mr-5px" /> 导出
        </el-button>
      </el-form-item>
    </el-form>
  </ContentWrap>

  <!-- 列表 -->
  <ContentWrap>

    <el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true">
      <el-table-column label="序号" type="index" :index="(i)=>i+1" align="center" min-width="60px" fixed/>
        

        
		<!-- <el-table-column label="主键id" align="center" prop="id" fixed/>  -->
        
      <el-table-column label="员工名称" align="center" prop="employeeName" />
        
      <el-table-column label="员工编号" align="center" prop="employeeCode" />
        
      <el-table-column label="工作经历" align="center" prop="workBackground" />
        
      <el-table-column label="性别" align="center" prop="sex" />
        
      <el-table-column label="年龄" align="center" prop="age" />
        
      <el-table-column label="兴趣爱好" align="center" prop="hobbies" />
        
      <el-table-column label="学历" align="center" prop="education" />
        
      <el-table-column label="打卡时间" align="center" prop="officeHours" />
        
      <el-table-column label="工作时间" align="center" prop="workingHours" />
        
      <el-table-column label="出生日期" align="center" prop="birth" />
        
      <el-table-column label="工作起止" align="center" prop="workDateFrom" />
        
      <el-table-column label="信息保密" align="center" prop="privacy" />
        
      <el-table-column label="自评分数" align="center" prop="selfRatingScore" />
        
      <el-table-column label="意见" align="center" prop="opinion" />
        
      <el-table-column label="是否可上岗" align="center" prop="mountGuard" />
        
      <el-table-column
        label="创建时间"
        align="center"
        prop="createTime"
        :formatter="dateFormatter"
        width="180px"
      />
        
      <el-table-column label="完成进度" align="center" prop="slider21678" />
      <el-table-column label="操作" align="center" min-width="160px" fixed="right">
        <template #default="scope">
          <el-button
            link
            type="primary"
            @click="openForm('update', scope.row.id)"
            v-hasPermi="['form:emp-info:update']"
          >
            编辑
          </el-button>
          <el-button
            link
            type="primary"
            @click="openDetail('detail', scope.row.id)"
            v-hasPermi="['form:emp-info:query']"
          >
            详情
        </el-button>
          <el-button
            link
            type="danger"
            @click="handleDelete(scope.row.id)"
            v-hasPermi="['form:emp-info:delete']"
          >
            删除
          </el-button>
        </template>
      </el-table-column>
    </el-table>
    <!-- 分页 -->
    <Pagination
      :total="total"
      v-model:page="queryParams.pageNo"
      v-model:limit="queryParams.pageSize"
      @pagination="getList"
    />
  </ContentWrap>

  <!-- 表单弹窗：添加/修改 -->
  <EmpInfoForm ref="formRef" @success="getList" />

  <!-- 表单弹窗：详情 -->
  <EmpInfoDetail ref="detailRef" />

</template>

<script setup lang="ts">
import { dateFormatter } from '@/utils/formatTime'



import download from '@/utils/download'
import { EmpInfoApi, EmpInfoVO } from '@/api/form/empinfo/index'
import EmpInfoForm from './EmpInfoForm.vue'
import EmpInfoDetail from './EmpInfoDetail.vue'




/** 审批员工信息 列表 */
defineOptions({ name: 'EmpInfo' })

const message = useMessage() // 消息弹窗
const { t } = useI18n() // 国际化

const loading = ref(true) // 列表的加载中
const list = ref<EmpInfoVO[]>([]) // 列表的数据
// 列表的总页数
const total = ref(0)
const queryParams = reactive({
  pageNo: 1,
  pageSize: 10,
  id: undefined,
  employeeName: undefined,
  employeeCode: undefined,
  workBackground: undefined,
  sex: undefined,
  age: undefined,
  hobbies: undefined,
  education: undefined,
  officeHours: undefined,
  workingHours: undefined,
  birth: undefined,
  workDateFrom: undefined,
  privacy: undefined,
  selfRatingScore: undefined,
  opinion: undefined,
  mountGuard: undefined,
  createTime: [],
  slider21678: undefined,
})
const queryFormRef = ref() // 搜索的表单
const exportLoading = ref(false) // 导出的加载中

/** 查询列表 */
const getList = async () => {
  loading.value = true
  try {
    const data = await EmpInfoApi.getEmpInfoPage(queryParams)
    list.value = data.list
    total.value = data.total
  } finally {
    loading.value = false
  }
}

/** 搜索按钮操作 */
const handleQuery = () => {
  queryParams.pageNo = 1
  getList()
}

/** 重置按钮操作 */
const resetQuery = () => {
  queryFormRef.value.resetFields()
  handleQuery()
}

/** 添加/修改操作 */
const formRef = ref()
const openForm = (type: string, id?: number) => {
  formRef.value.open(type, id)
}

/** 详情操作 */
const detailRef = ref()
const openDetail = (type: string, id?: number) => {
    detailRef.value.open(type, id)
}

/** 删除按钮操作 */
const handleDelete = async (id: number) => {
  try {
    // 删除的二次确认
    await message.delConfirm()
    // 发起删除
    await EmpInfoApi.deleteEmpInfo(id)
    message.success(t('common.delSuccess'))
    // 刷新列表
    await getList()
  } catch {}
}

/** 导出按钮操作 */
const handleExport = async () => {
  try {
    // 导出的二次确认
    await message.exportConfirm()
    // 发起导出
    exportLoading.value = true
    const data = await EmpInfoApi.exportEmpInfo(queryParams)
    download.excel(data, '审批员工信息.xls')
  } catch {
  } finally {
    exportLoading.value = false
  }
}




/** 初始化 **/
onMounted(() => {
  getList()
})
</script>